<?php

namespace app\admin\controller\promotion;

use app\admin\service\PromotionGroupFieldService;
use app\admin\traits\DefaultTimeTrait;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\TimeUtil;
use think\APP;
use think\exception\ValidateException;
use think\Request as Request;

/**
 * 渠道数据统计 多小组全字段对比
 * Class PromotionTableField
 * @package app\admin\controller\promotion
 */
class PromotionTableGroup
{
    use DefaultTimeTrait;

    // 请求参数
    private Request $request;
    private PromotionGroupFieldService $service;

    public function __construct(Request $request, PromotionGroupFieldService $service)
    {
        $this->request = $request;
        $this->service = $service;
    }

    /**
     * @return ApiResponse
     * @url /promotion/promotion_table_group/index
     * @deprecated
     */
    public function index()
    { 
        $promotionGroupIds = \app\common\model\PromotionGroup::where('isDel', '0')
            ->select()
            ->column('id');

        ['startTime' => $startTime, 'endTime' => $endTime] = $this->defaultStartAndEndTime(TimeUtil::DAY);

        return ApiResponse::success($this->service->index($promotionGroupIds, $startTime, $endTime));
    }
}
